package com.ishansong.ticket.service.impl;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ishansong.ticket.exception.ServiceDaoException;
import com.ishansong.ticket.exception.ServiceException;
import com.ishansong.ticket.model.${mo};
import com.ishansong.ticket.service.${mo}Service;
import com.matrixjoy.dal.dao.Dao;
import com.matrixjoy.dal.dao.exception.DaoException;



@Component( value= "${mop}Service" ) 
public class ${mo}ServiceImpl implements ${mo}Service {

	
	@Autowired
	private Dao dao;

	@Override
	public Boolean delete${mo}(Long id) throws ServiceDaoException, ServiceException {
		try {
			return (Boolean) dao.delete(${mo}.class, id);
		} catch (DaoException e) {
			throw new ServiceDaoException(e);
		}
	}

	@Override
	public ${mo} get${mo}(Long id) throws ServiceDaoException, ServiceException {
		try {
			if (null == id) {
				return null;
			}
			return (${mo}) dao.get(${mo}.class, id);
		} catch (DaoException e) {
			throw new ServiceDaoException(e);
		}
	}

	@Override
	public Long save${mo}(${mo} ${mop}) throws ServiceDaoException, ServiceException {
		try {
			return (Long) dao.save(${mop});
		} catch (DaoException e) {
			throw new ServiceDaoException(e);
		}
	}

	@Override
	public void update${mo}(${mo} ${mop}) throws ServiceDaoException, ServiceException {
		try {
			dao.update(${mop});
		} catch (DaoException e) {
			throw new ServiceDaoException(e);
		}

	}

	public Dao getDao() {
		return dao;
	}

	public void setDao(Dao dao) {
		this.dao = dao;
	}

}
